package com.ibeetl.dao.hbatis.service;

import com.ibeetl.dao.common.TestServiceInterface;
import com.ibeetl.dao.hbatis.entity.HbatisUser;

import cn.sylinx.hbatis.ext.starter.util.DAO;
import cn.sylinx.hbatis.kit.Pair;

public class HbatisPerformanceTestService implements TestServiceInterface {

	int index = 1;

	@Override
	public void testAdd() {
		DAO.hbatis().addObject(getNewUser());
	}

	@Override
	public void testUnique() {
		HbatisUser user = DAO.hbatis().get(1, HbatisUser.class);
	}

	@Override
	public void testUpdateById() {
		HbatisUser user = new HbatisUser();
		user.setId(1);
		user.setCode("abc");
		DAO.hbatis().update(user);
	}

	@Override
	public void testPageQuery() {
		DAO.hbatis().queryPage(HbatisUser.class, 1, 10);
	}

	@Override
	public void testExampleQuery() {
		HbatisUser user = DAO.hbatis().getObjectByField(Pair.apply("id", 1), HbatisUser.class);
	}

	@Override
	public void testOrmQUery() {
	}

	private HbatisUser getNewUser() {
		HbatisUser user = new HbatisUser();
		user.setId(index++);
		user.setCode("abc");
		return user;
	}

}
